<%--
  Created by IntelliJ IDEA.
  User: 王长hui
  Date: 2022/10/15
  Time: 11:22
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link type="text/css" rel="stylesheet" href="/css/moregood.css"/>
    <link type="text/css" rel="stylesheet" href="/css/index.css"/>
    <!--引入vue得依赖必须再elementui之前引入vue-->
    <script type="text/javascript" src="/js/vue.js"></script>
    <script type="text/javascript" src="/js/index.js"></script>
    <script type="text/javascript" src="/js/axios.min.js"></script>
    <script type="text/javascript" src="/js/qs.min.js"></script>
</head>
<body>
<div id="app">
    <el-table
            :data="tableData"
            border
            style="width: 100%"
            :cell-style="styleBack"
            :header-cell-style="getRowClass"

    >
        <el-table-column
                prop="mId"
                label="编号"
                width="100">
        </el-table-column>
        <el-table-column
                prop="mIdcard"
                label="身份证号"
                width="250">
        </el-table-column>
        <el-table-column
                prop="mTelephone"
                label="电话号码"
                width="180">
        </el-table-column>
        <el-table-column
                prop="mSex"
                label="性别"
                width="100">
        </el-table-column>
        <el-table-column
                prop="mAge"
                label="年龄"
                width="100">
        </el-table-column>

        <el-table-column
                prop="mPrice"
                label="收费"
                width="100">
        </el-table-column>

        <el-table-column
                prop="mNum"
                label="剩余预约人数"
                width="100">
        </el-table-column>

        <el-table-column
                prop="mDate"
                label="预约时间"
                width="180">
        </el-table-column>

        <el-table-column
                prop="mYstatus"
                label="预约状态"
                width="180">
            <template slot-scope="scope">
                <el-tag size="small" type="danger" v-if="scope.row.mYstatus == 0">未预约</el-tag>
                <el-tag size="small" type="success" v-else-if="scope.row.mYstatus !==0 ">已预约</el-tag>
                <el-tag size="small" v-else>暂未</el-tag>

            </template>
        </el-table-column>

        <el-table-column
                prop="mZstatus"
                label="支付状态"
                width="180">
            <template slot-scope="scope">
                <el-tag size="small" type="danger" v-if="scope.row.mZstatus == 0">未支付</el-tag>
                <el-tag size="small" type="success" v-else-if="scope.row.mZstatus == 1">支付成功</el-tag>
                <el-tag size="small" v-else>暂未</el-tag>

            </template>
        </el-table-column>

        <el-table-column
                prop="condition"
                label="处理状态"
                width="180">
            <template slot-scope="scope">
                <el-tag size="small" type="danger" v-if="scope.row.condition.cId !== 0">已处理</el-tag>
                <el-tag size="small" type="success" v-else-if="scope.row.condition.cId == 0">未处理</el-tag>
                <el-tag size="small" v-else>暂未</el-tag>

            </template>
        </el-table-column>

        <el-table-column
                fixed="right"
                label="操作"
                width="330">
            <template slot-scope="scope">
                <el-button type="success" @click="chuli(scope.row)">处理</el-button>
                <el-button type="success" @click="editEmp(scope.row)">修改</el-button>
                <el-button type="danger" @click="del(scope.row)">删除</el-button>
            </template>
        </el-table-column>

    </el-table>


    <el-dialog
            title="提示"
            :visible.sync="dialogVisible"
            width="30%"
    >
        <!--:model:绑定表单数据-->
        <el-form :model="updateForm" label-width="110px">
            <el-form-item label="身份证号" prop="newsTitle">
                <el-input v-model="updateForm.mIdcard" class="ab"></el-input>
            </el-form-item>
            <el-form-item label="手机号" prop="newsTitle">
                <el-input v-model="updateForm.mTelephone" class="ab"></el-input>
            </el-form-item>
            <el-form-item label="性别" prop="newsTitle">
                <el-input v-model="updateForm.mSex" class="ab"></el-input>
            </el-form-item>
            <el-form-item label="年龄" prop="newsTitle">
                <el-input v-model="updateForm.mAge" class="ab"></el-input>
            </el-form-item>

        </el-form>
        <span slot="footer" class="dialog-footer">
            <el-button @click="dialogVisible = false">取 消</el-button>
            <el-button type="primary" @click="confirmUpdate()">确认修改</el-button>

        </span>
    </el-dialog>


    <%--医生处理意见--%>
    <el-dialog
            title="提示"
            :visible.sync="dialogVisible1"
            width="30%"
    >
        <!--:model:绑定表单数据-->
        <el-form :model="advice" label-width="110px">
            <el-form-item label="病情" prop="newsTitle">
                <el-input v-model="advice.cCases" class="ab"></el-input>
            </el-form-item>
            <el-form-item label="医嘱" prop="newsTitle">
                <el-input v-model="advice.cSuggest" class="ab"></el-input>
            </el-form-item>

        </el-form>
        <span slot="footer" class="dialog-footer">
            <el-button @click="dialogVisible1 = false">取 消</el-button>
            <el-button type="primary" @click="tijiaoad">提交建议</el-button>

        </span>
    </el-dialog>


</div>
</body>
<script>
    var app = new Vue({
        el: "#app",
        data: {
            dialogVisible: false,
            dialogVisible1: false,
            editForm: {},
            tableData: [],
            updateForm: {},
            advice: {},

            //如果不是医生处理的默认为1
            dId: 1,
            //病例id
            cId: 0,
        },
        created() {
            this.initTable();
            this.getuser();
        },
        methods: {

            tijiaoad() {

                axios.post("/condition/updateAdvise",this.advice).then(resp=>{
                    this.$message.success("医嘱信息成功");
                    this.dialogVisible1 = false;
                })
            },

            selectOne() {
                axios.get("/condition/one?cId=" + this.cId).then(resp => {
                    this.advice = resp.data.data
                    this.dialogVisible1 = true;
                })
            },

            //处理
            chuli(row) {

                this.cId = row.cId

                axios.get("/messagebook/updated?mId=" + row.mId + "&dId=" + this.dId).then(resp => {
                    this.selectOne();
                    this.dialogVisible1 = true;
                })
            },
            //确认修改
            confirmUpdate() {
                axios.post("/messagebook/update", this.updateForm).then(resp => {
                    if (resp.data.code === 200) {
                        this.$message.success("修改员工信息成功");
                        //关闭表单弹窗
                        this.dialogVisible = false;
                        //重新加载表格数据
                        this.initTable();
                    }
                })
            },

            //点击修改
            editEmp(row) {
                this.dialogVisible = true;
                //在此转json是为了把数据固定阻断双向绑定里面的数据同步
                let parse = JSON.parse(JSON.stringify(row));
                this.updateForm = parse;
            },
            //删除数据
            del(row) {
                axios.post("messagebook/delete?mId=" + row.mId).then(resp => {
                    if (resp.data.code) {
                        this.$message.success("删除成功");
                        this.initTable();
                    }
                })
            },
            initTable() {
                axios.post("/messagebook/list").then(resp => {
                    console.log(resp)
                    this.tableData = resp.data.data;
                })
            },
            //得到当前已经登录的用户的职业（权限）名字
            getuser() {
                axios.post("/login/getuser").then(result => {

                    if (result.data.code === 5025) {

                        if (result.data.data.dId != null) {
                            this.dId = result.data.data.dId
                        } else {
                            this.dId = 1
                        }
                    }
                })
            },
            // 表格奇偶层样式
            styleBack({ row, column, rowIndex, columnIndex }) {
                if ((rowIndex + 1) % 2 === 0) {
                    return "background:#053c4a; color:#fff;border:1px solid #053c4a";
                } else {
                    return "background:#042831; color:#fff;border:1px solid #042831";
                }
            },
            // 表头样式
            getRowClass({ rowIndex }) {
                return "background:#053c4a; color:#fff;border:3px solid #053c4a";
            },


        }
    })
</script>
</html>
